package officers;

public class Problem28 {
    public boolean isSymmetric(TreeNode root) {
        return root == null ? true : recur(root.left, root.right);
    }
/*
    boolean recur(TreeNode L, TreeNode R) {
        if (L == null && R == null) return true;
        if (L == null || R == null || L.val != R.val) return false;
        return recur(L.left, R.right) && recur(L.right, R.left);
    }*/

    boolean recur(TreeNode left, TreeNode right) {
      if (left == null && right == null ) return true;
      if (left == null || right == null || left.val != right.val) return false;
      return recur(left.left,right.right) && recur(left.right,right.left);
    }
}
